/**
 * 您的公司.com
 * Copyright (c) 2018-2018 All Rights Reserved.
 */
package com.mei.demo.Thread;

/**
 * 实现 Runnable 实现多线程
 *
 * @author mei.xiaoliang@qq.com
 */
public class Demo5 {

    public static void main(String[] args) {
        Thread t1 = new Thread(new thread5());
        t1.start();
        try {
            Thread.sleep(2000);
            System.out.println("让你睡 2 s");
        } catch (InterruptedException e) {

        }
        if (!t1.isInterrupted()) {
            System.out.println("打断睡眠");
            t1.interrupt();
        }
    }
}

class thread5 implements Runnable {

    @Override
    public void run() {
        try {
            System.out.println("开始睡眠 10 s");
            Thread.sleep(10000);
            System.out.println("睡眠 over");
        } catch (InterruptedException e) {
            System.out.println("线程被中断了！");
        }
    }

}